window.addEventListener('DOMContentLoaded', function() {
    var tip = document.querySelector('.tip');
    this.document.addEventListener('scroll', function() {
        if (window.pageYOffset >= 100) {
            tip.style.position = 'fixed';
            tip.style.top = 50 + 'px';
        }else {
            tip.style.position = 'absolute';
            tip.style.top = 150 + 'px';
        }
    })
    tip.addEventListener('click', function() {
        if (this.tip) return;
        this.tip = true;
        var topDis = window.pageYOffset;
        this.timer = setInterval(() => {
            if (window.pageYOffset == 0) {
                clearInterval(this.timer);
            }else {
                topDis -= Math.min(10, topDis);
                window.scrollTo (0, topDis);
            }
        }, 25);
    })
})
